package cn.fy.appcode.notification;

import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class NotificationBroadcastReceiver extends BroadcastReceiver {

    public static final String TYPE = "type"; //这个type是为了Notification更新信息的
    public static final int NOTIFICATION_ID = 1;

    @Override

    public void onReceive(Context context, Intent intent) {
        Log.e(getClass().getName(), "onReceive");

        String action = intent.getAction();

        int type = intent.getIntExtra(TYPE, -1);

        if (type != -1) {

            NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

            notificationManager.cancel(NOTIFICATION_ID);

        }

        if (action.equals("notification_clicked")) {
            //处理点击事件
        }

        if (action.equals("notification_cancelled")) {
            //处理滑动清除和点击删除事件
        }
    }
}